<html>
<head><meta charset="utf-8"><title>proc_macro_hack and asan · wg-secure-code · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/index.html">wg-secure-code</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/proc_macro_hack.20and.20asan.html">proc_macro_hack and asan</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="201933708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/proc_macro_hack%20and%20asan/near/201933708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jsha <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/proc_macro_hack.20and.20asan.html#201933708">(Jun 25 2020 at 05:28)</a>:</h4>
<p>When I export RUSTFLAGS="-Zsanitizer=address" and build the time-macros-impl crate, I get this error:</p>
<div class="codehilite"><pre><span></span><code>   Compiling time-macros-impl v0.1.1 (/home/jsha/rust/time-macros-impl/time-macros-impl)
error: /home/jsha/rust/time-macros-impl/target/debug/deps/libproc_macro_hack-482955eb312b4504.so: undefined symbol: __asan_option_detect_stack_use_after_return
  --&gt; time-macros-impl/src/lib.rs:89:5
   |
89 | use proc_macro_hack::proc_macro_hack;
   |     ^^^^^^^^^^^^^^^
</code></pre></div>


<p>Any idea what could cause this? It came up when trying to build ureq with the address sanitizer for smoke testing; time-macros-impl is in its dependency tree with the default features. I can work around by turning off features but I'd like to see if it's fixable in general.</p>



<a name="201937984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/proc_macro_hack%20and%20asan/near/201937984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/proc_macro_hack.20and.20asan.html#201937984">(Jun 25 2020 at 07:07)</a>:</h4>
<p><code>proc_macro_hack</code> really just defines a weird enum internally</p>



<a name="201937991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/proc_macro_hack%20and%20asan/near/201937991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/proc_macro_hack.20and.20asan.html#201937991">(Jun 25 2020 at 07:07)</a>:</h4>
<p>so... this is strange, and possibly reproducible even without it</p>



<a name="201955422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/proc_macro_hack%20and%20asan/near/201955422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/proc_macro_hack.20and.20asan.html#201955422">(Jun 25 2020 at 11:07)</a>:</h4>
<p><span class="user-mention" data-user-id="315412">@jsha</span> sounds like you're compiling proc macros with ASAN too. Make sure you pass <code>--target x86_64-unknown-linux-gnu</code> to <code>cargo build</code> so that it would apply ASAN only to the generated code.</p>



<a name="201956013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/proc_macro_hack%20and%20asan/near/201956013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/proc_macro_hack.20and.20asan.html#201956013">(Jun 25 2020 at 11:16)</a>:</h4>
<p>now that I look at it, the requirement to always pass <code>--target</code> explicitly is documented in <a href="https://github.com/japaric/rust-san">https://github.com/japaric/rust-san</a> but not in <a href="https://doc.rust-lang.org/unstable-book/compiler-flags/sanitizer.html">https://doc.rust-lang.org/unstable-book/compiler-flags/sanitizer.html</a></p>



<a name="201956164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/proc_macro_hack%20and%20asan/near/201956164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/proc_macro_hack.20and.20asan.html#201956164">(Jun 25 2020 at 11:18)</a>:</h4>
<p>oh it <em>is</em> documented, just at the very bottom of the page</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>